import axiosInstance from '@/js/axiosself'

import {
    ElMessage
} from 'element-plus';

export default {
    async uploadImg(params) {
        try{
        // 使用FormData传参数和文件
        const form = new FormData();
        // 添加键值对
        form.append("file", params.file);
        const resp = await axiosInstance.post("/common/upload", form);

        if (resp.data.code == 1) {
            return resp.data.data;
        } else if (resp.data.code == 0) {
            ElMessage.error(resp.data.msg);
            return null;
        }
    }catch(error){
        ElMessage.error(error);
        return null
    }

    }
}